﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using A2DFramework;
using A2DFramework.InstanceService;

namespace Demo.SqlDispatcherConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Starter.Init();

            

            //Console.WriteLine("============");
            //for (int i = 0; i < 1;i++ )
            //    q.Test0();

            //Console.WriteLine("============");
            //for (int i = 0; i < 15; i++)
            //    q.Test1();

            //Console.WriteLine("============");
            //for (int i = 0; i < 15; i++)
            //    q.Test2();

            var t1 = new Task(()=>Test());
            var t2 = new Task(() => Test());
            //var t3 = new Task(() => Test());
            //var t4 = new Task(() => Test());
            //var t5 = new Task(() => Test());
            //var t6 = new Task(() => Test());
            //var t7 = new Task(() => Test());
            //var t8 = new Task(() => Test());
            //var t9 = new Task(() => Test());
            //var t10 = new Task(() => Test());

            t1.Start();
            t2.Start();
            //t3.Start();
            //t4.Start();
            //t5.Start();
            //t6.Start();
            //t7.Start();
            //t8.Start();
            //t9.Start();
            //t10.Start();

            Task.WaitAll(t1, t2/*, t3, t4, t5, t6, t7, t8, t9, t10*/);

            Console.WriteLine("done.");
            Console.ReadKey();
        }

        private static void Test()
        {
            Query1 q = new Query1();

            int i = 20;
            DateTime from = DateTime.Now;
            while (i-- > 0)
            {
                q.Test_2Write();
                if (i % 5 == 0)
                    Console.Write(i + ", ");
            }
            TimeSpan elapsed = DateTime.Now - from;
            Console.WriteLine(string.Format("Total {0} seconds", elapsed.TotalSeconds));

            i = 20;
            from = DateTime.Now;
            while (i-- > 0)
            {
                q.Test_1Read1Write();
                if (i % 5 == 0)
                    Console.Write(i + ", ");
            }
            elapsed = DateTime.Now - from;
            Console.WriteLine(string.Format("Total {0} seconds", elapsed.TotalSeconds));
        }
    }
}
